package com.nbgroup.controller;

import com.nbgroup.annotation.HttpMethod;
import com.nbgroup.pojo.common.PageResult;
import com.nbgroup.pojo.common.Result;
import com.nbgroup.pojo.User;
import com.nbgroup.pojo.dto.PageTransferDto;
import com.nbgroup.pojo.vo.CompanyVo;
import com.nbgroup.pojo.vo.TransferDataVo;
import com.nbgroup.service.TransferService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.License;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;


/**
 * 转派管理
 */
@RestController
@Slf4j
@RequestMapping
@Api(tags = "转派管理接口")
public class TransferController {
    @Autowired
    private TransferService transferService;


    /**
     * 转派管理分页查询
     * @param dto
     * @return
     */
    @HttpMethod("GET")
    @GetMapping("/transfer/list")
    @ApiOperation("转派分页")
    public PageResult list(PageTransferDto dto) {
        return transferService.list(dto);
    }

    // @GetMapping("/system/dept/treeselect")
    @ApiOperation("处理")
    public Result select() {
        ArrayList<CompanyVo> l = transferService.select();
        return Result.success(l);
    }


    /**
     *用户回显报错 写不来了 。。。。。。。。。。。 晕
     */
    @GetMapping("/system/user/listselect")
    @ApiOperation("回显部门列表")
    public Result deptList(Integer deptId) {
        List<User> l = transferService.userList(deptId);
        return Result.success(l);
    }


    //写不来
    @PutMapping("/transfer/assignment/{status}/{deptId}/{id}")
    @ApiOperation("转派确认")
    public Result assignment(@PathVariable Integer status,@PathVariable Integer deptId,@PathVariable Integer id){
        TransferDataVo vo = transferService.assigment(status,deptId,id);
        return Result.success(vo);
    }
}
